﻿#region Imports
using System;
using System.Windows.Forms;
using CommonUtilities.Extensions;
#endregion Imports

namespace CommonUtilities.Util
{
    public class DialogInitializers
    {
        /// <summary>
        /// 
        /// </summary>
        /// <param name="title">Title</param>
        /// <param name="defaultExt">Default extnsion
        /// <para>( e.g. txt)</para></param>
        /// <param name="filter">Extension filters
        /// <para>( e.g. Text files (*.txt)|*.txt|All files (*.*)|*.* )</para></param>
        /// <param name="initialDirectory">Intial directory</param>
        /// <param name="fileName"></param>
        /// <returns></returns>
        public static OpenFileDialog Create_OpenFileDialog(string title = "<Enter Title>",
            string defaultExt = "", string filter = "All files (*.*)|*.*",
            string initialDirectory = "", string fileName = "")
        {
            return new OpenFileDialog
            {
                Title = title,
                AddExtension = true,
                CheckFileExists = true,
                CheckPathExists = true,
                DefaultExt = defaultExt,
                Filter = filter,
                InitialDirectory = initialDirectory.IsBlank() ? Environment.SpecialFolder.Desktop.GetFolderPath() : initialDirectory,
                FileName = fileName,
                RestoreDirectory = true,
                Multiselect = false,
                ValidateNames = true
            };
        }

        public static FolderBrowserDialog Create_FolderBrowserDialog(string desc = "<Enter Description>",
            string path = "", Environment.SpecialFolder root = Environment.SpecialFolder.Desktop)
        {
            return new FolderBrowserDialog
            {
                Description = desc,
                RootFolder = root,
                SelectedPath = path,
                ShowNewFolderButton = true
            };
        }
    }
}
